<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of debug
 *
 * @author jpsiffert
 */
class debug extends base {
  
  private static $_debug_lines = array();
  
  /**
   * Log message into class
   * @param string or array $txt 
   */
  public static function log($txt){
    if(!is_array($txt)){
      $txt = array($txt);
    }
    foreach($txt as $texte){
      self::$_debug_lines[] = $texte;
    }
    css::addPartial('debug.css');
  }
  
  /**
   * Fetch debug layout
   * @return string 
   */
  public static function fetch(){
    if(count(self::$_debug_lines)==0){
      return '';
    }
    $smarty = commun::getSmartyPartial();
    $smarty->assign('lignes',self::$_debug_lines);
    $ret = $smarty->fetch('debug.'.TPL_EXT);
    return $ret;
  }
  
  /**
   * Fetch and display debug values
   */
  public static function render(){
    $ret = self::fetch();
    echo $ret;
  }
}

